package com.ghp.common.exception;

import com.ghp.common.utils.response.ResponseStatus;

import static com.ghp.common.utils.response.ResponseStatus.SYSTEM_ERROR;

/**
 * @author ghp
 * @title 业务异常
 * @description
 */
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    private int code;

    public int getCode() {
        return code;
    }

    public BusinessException(String message) {
        super(message);
        this.code = SYSTEM_ERROR.getCode();
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(ResponseStatus responseStatus) {
        super(responseStatus.getMessage());
        this.code = responseStatus.getCode();
    }

}